﻿using SmartSpace.Orgs;
using SmartSpace.Web;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SmartSpace.WebApp.Modules.Orgs.Pages
{
    public partial class Org_Employee_List : SsTemplatePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            String nodeId = Request.QueryString["nodeId"] ?? String.Empty;

            if (nodeId == "")
            {
                add_employee.Enabled = false;
            }
            else
            {
                add_employee.Enabled = true;
                add_employee.NavigateUrl = "Org-Employee-Assign.aspx?nodeId=" + nodeId;
            }

            if (!IsPostBack)
            {
                BindEmployeeByNodeId();
            }
        }

        public void BindEmployeeByNodeId()
        {
            Guid nodeId = Request.GetGuid("nodeId");
            if (nodeId != Guid.Empty)
            {
                OrgsService service = new OrgsService();
                PagedList<Employee> list = service.GetEmployees(nodeId, 0, 9999);
                rep1.DataSource = list;
                rep1.DataBind();
            }
        }

        protected void link_back_Click(object sender, EventArgs e)
        {
            String nodeId = Request.QueryString["nodeId"] ?? string.Empty;
            Response.Redirect("OrgTree.aspx?nodeId=" + nodeId);
        }
    }
}